#ifndef PLAYER_H
#define PLAYER_H
#include "multiSprite.h"
#include "gamedata.h"
#include "multiFrameFactory.h"

class Player:public MultiSprite {
public:
	Player():
	MultiSprite(Vector2f(Gamedata::getInstance()->getXmlInt("barPosX"),
						 Gamedata::getInstance()->getXmlInt("barPosY")),
				Vector2f(0,0),
				MultiFrameFactory::getInstance()->getFrame("barnormal","barnormal"),
				"barnormal"),life(Gamedata::getInstance()->getXmlInt("playerLife")),length(NORMAL){
		
	}
	virtual ~Player(){cout<<"delete player"<<endl;}
	virtual void draw() const;
	virtual void update(unsigned ticks);
	void move(int direction);
	void stop();
	
	void rewardLife(){
		++life;
	}
	void lostLife() {
		--life;
		resetLength();
	}
	
	int getLife() const {
		return life;
	}
	void increaseLength(){
		if(length != LONG){
			++length;
		}
		cout<<"LENGTH:"<<length<<endl;
		setFrame();
	}
	void decreaseLength(){
		if(length != SHORT){
			--length;
		}
		cout<<"LENGTH:"<<length<<endl;
		setFrame();
	}	
	void resetLength(){
	  length = NORMAL;
	  cout<<"LENGTH:"<<length<<endl;
	  setFrame();
	}
	void setFrame();
	enum{SHORT,NORMAL,LONG};
private:
	int life;
	int length;
	};
#endif
